%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% This file is part of the book
%%
%% Probability and Its Applications
%% http://code.google.com/p/probability-book/
%%
%% Copyright (C) 2010 Minh Van Nguyen <nguyenminh2@gmail.com>
%%
%% See the file COPYING for copying conditions.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage[latin1]{inputenc}

%% For typesetting algorithms and pseudocode
\usepackage[algochapter,linesnumbered,noend,ruled]{algorithm2e}
\incmargin{1em}
\decmargin{1em}
\Setnlsty{}{}{}  %% don't bold the line numbers
\SetAlTitleFnt{}  %% don't bold the text ``Algorithm'' in the caption
\setalcapskip{5pt}

\usepackage{amsmath,amssymb,amsthm}
\usepackage{graphicx,url}
\usepackage{makeidx}
\usepackage{xspace}
\usepackage{enumerate}
\usepackage{fancyvrb}
\usepackage{moreverb}

%% Customized corollary, lemma, theorem, etc. numbering
\newtheorem{theorem}{Theorem}[chapter]
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{remark}[theorem]{Remark}
\newtheorem{definition}[theorem]{Definition}  %% maybe don't need to use this
\newtheorem{example}[theorem]{Example}
\newtheorem{exercise}[theorem]{Exercise}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}

%% Package for drawing figures
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{calc}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{matrix}
\usetikzlibrary{trees}
\usepackage{pgfplots}
\usepackage{subfigure}

%% For typesetting code listings
\usepackage{listings}
\lstdefinelanguage{Sage}[]{Python}
{morekeywords={False,sage,True},sensitive=true}
\lstset{
  frame=none,
  showtabs=False,
  showspaces=False,
  showstringspaces=False,
  commentstyle={\ttfamily\color{dgreencolor}},
  keywordstyle={\ttfamily\color{dbluecolor}\bfseries},
  stringstyle={\ttfamily\color{dgraycolor}\bfseries},
  language=Sage,
  basicstyle={\fontsize{9pt}{9pt}\ttfamily},
  aboveskip=0.5em,
  belowskip=0.5em,
  %% numbers=left,
  numberstyle=\footnotesize
}
\definecolor{dblackcolor}{rgb}{0.0,0.0,0.0}
\definecolor{dbluecolor}{rgb}{0.01,0.02,0.7}
\definecolor{dgreencolor}{rgb}{0.2,0.4,0.0}
\definecolor{dgraycolor}{rgb}{0.30,0.3,0.30}
\newcommand{\dblue}{\color{dbluecolor}\bf}
\newcommand{\dred}{\color{dredcolor}\bf}
\newcommand{\dblack}{\color{dblackcolor}\bf}

%% Customized page geometry
\textwidth=450pt
\textheight=700pt
\topmargin=-30pt
\oddsidemargin=0.0pt
\evensidemargin=0.0pt

%% Format date in the ISO format 2007 March 12, for example.
\usepackage{datetime}
\newdateformat{isoDateFormat}{%
  \THEYEAR~\monthname[\THEMONTH]~\twodigit{\THEDAY}
}
\isoDateFormat

%% Custom commands and shortcuts
%% the latest version of this document
\newcommand{\documentEdition}{\input{tex/version}}
\newcommand{\E}{\mathbf{E}}  %% expectation of a random variable
\newcommand{\R}{\mathbf{R}}  %% set of real numbers
\newcommand{\Z}{\mathbf{Z}}  %% set of integers

%% Define new operators
\DeclareMathOperator*{\Cov}{Cov}  %% covariance of random variables
\DeclareMathOperator*{\Var}{Var}  %% variance of random variables

%% Custom renewal of existing commands
%% The following is a brute-force way to prevent the headers from
%% getting transformed into all-caps
\renewcommand{\MakeUppercase}{}
\renewcommand{\mapsto}{\longmapsto}  %% function image A |--> B
\renewcommand{\qed}{\hfill \mbox{\raggedright \rule{0.1in}{0.1in}}}
\renewcommand{\to}{\longrightarrow}  %% function notation f: A -> B

%% Custom environments
%% For listing problem sets. Each problem is numbered according to the
%% format
%%
%% chapterNumber.problemNumber.
\newcounter{problemcounter}
\newenvironment{problem}{%
  \setcounter{problemcounter}{1}
  \begin{list}
    {\thechapter.\arabic{problemcounter}.}
    {\usecounter{problemcounter}}
    \let\olditem\item}{%
  \end{list}
}

\makeindex
\usepackage{hyperref}
\hypersetup{
  pdftitle={Probability and Its Applications},%
  pdfauthor={Minh Van Nguyen},%
  pdfsubject={mathematics},%
  colorlinks=true,%
  linkcolor=black,%
  citecolor=black,%
  urlcolor=black
}
